| Total Complexity | 2 |
| Total Lines | 16 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import { Inject } from '@nestjs/common'; |
||
| 6 | |||
| 7 | @CommandHandler(RemoveVoucherCommand) |
||
| 8 | export class RemoveVoucherCommandHandler { |
||
| 9 | constructor( |
||
| 10 | @Inject('IVoucherRepository') |
||
| 11 | private readonly voucherRepository: IVoucherRepository, |
||
| 12 | ) {} |
||
| 13 | |||
| 14 | public async execute({ id }: RemoveVoucherCommand): Promise<void> { |
||
| 15 | const voucher = await this.voucherRepository.findOneById(id); |
||
| 16 | |||
| 17 | if (!voucher) { |
||
| 18 | throw new VoucherNotFoundException(); |
||
| 19 | } |
||
| 20 | |||
| 21 | await this.voucherRepository.remove(voucher); |
||
| 22 | } |
||
| 24 |